var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function s() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((s.prototype = i.prototype), new s()));
      };
    })(),
  AXGemFusionView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        t.btn_gemFunsion_cancle.on(Laya.Event.CLICK, t, t.onGemFunsionBackFn),
        t.label_gemSetLv.on(Laya.Event.CLICK, t, t.onGemFunsionSelectLvAction),
        t.label_gemSetLv1.on(Laya.Event.CLICK, t, t.onGemFunsionSelectLvAction),
        (t.list_gemFunsion_select.vScrollBarSkin = ""),
        (t.list_gemFunsion_select.selectEnable = !0),
        t.list_gemFunsion_select.on(
          Laya.Event.CLICK,
          t,
          t.onListGemFunsionDidCLick
        ),
        (t.list_gem_item.vScrollBarSkin = ""),
        (t.list_gem_item.selectEnable = !0),
        t.list_gem_item.on(Laya.Event.CLICK, t, t.onListSelectGemDidClick),
        (t.list_gem_item.renderHandler = new Handler(
          t,
          t.onRenderGemItemHandler
        )),
        t.label_select_item_delete1.on(
          Laya.Event.CLICK,
          t,
          t.onSelectBaoShiDidClickAction
        ),
        t.label_select_item_delete2.on(
          Laya.Event.CLICK,
          t,
          t.onSelectBaoShiDidClickAction
        ),
        t.btn_kuaisuhecheng.on(Laya.Event.CLICK, t, t.onHeChengAction),
        t.btn_putonghecheng.on(Laya.Event.CLICK, t, t.onHeChengAction),
        t.btn_gemFusion_GZSM.on(Laya.Event.CLICK, t, t.onDidClickLookGZSM),
        WebSocketService.addListener({
          caller: t,
          code: 1284,
          method: t.onLoadBaoShiDataListFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1286,
          method: t.onLoadHeChengSuccessData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1274,
          method: t.onLoadGemFusionPersonalData,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showGemFunsionView = function () {
        return (
          null == this.gemFunsionV && (this.gemFunsionV = new t()),
          (this.gemFunsionV.label_gemSetLv.text = "1级"),
          (this.gemFunsionV.list_gemFunsion_select.visible = !1),
          (this.gemFunsionV.list_gem_item.visible = !1),
          WebSocketService.send({ c: 1284, d: { lvl: 1, pageNum: 0 } }),
          WebSocketService.send({ c: 1274 }),
          (this.gemFunsionV.curLvl = 1),
          this.gemFunsionV.initHasBaoShiSelected(),
          (this.gemFunsionV.firstObj = {}),
          (this.gemFunsionV.secondObj = {}),
          (this.gemFunsionV.label_putong_haoyin.text = ""),
          (this.gemFunsionV.label_kuaisu_haoyin.text = "（耗银：200）"),
          (this.gemFunsionV.label_gemfunsion_tip.text = ""),
          this.gemFunsionV
        );
      }),
      (t.prototype.onGemFunsionSelectLvAction = function () {
        var e = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"];
        this.resultArr = [];
        for (var t, i = 0; i < e.length; i++)
          (t = { item_bang: { text: e[i] + "级" } }), this.resultArr.push(t);
        (this.list_gemFunsion_select.visible = !0),
          (this.list_gemFunsion_select.dataSource = this.resultArr);
      }),
      (t.prototype.onListGemFunsionDidCLick = function (e) {
        if ("" != e.target.name && e.target.name) {
          var t = this.list_gemFunsion_select.selectedItem;
          (this.list_gemFunsion_select.visible = !1),
            (this.label_gemSetLv.text = t.item_bang.text);
          var i = this.list_gemFunsion_select.selectedIndex + 1;
          WebSocketService.send({ c: 1284, d: { lvl: i, pageNum: 0 } }),
            (this.curLvl = i),
            this.initHasBaoShiSelected(),
            (this.label_kuaisu_haoyin.text = "（耗银：" + 100 * (i + 1) + "）");
        }
      }),
      (t.prototype.initHasBaoShiSelected = function () {
        (this.label_select_item1.text = ""),
          (this.label_select_item2.text = ""),
          (this.image_select_icon1.skin = ""),
          (this.image_select_icon2.skin = ""),
          (this.label_putong_haoyin.text = ""),
          (this.label_select_item_delete1.visible = !1),
          (this.label_select_item_delete2.visible = !1),
          (this.btn_putonghecheng.disabled = !0);
      }),
      (t.prototype.onLoadBaoShiDataListFn = function (e) {
        if (0 == e.code) {
          (this.baoshiArr = []), (this.list_gem_item.visible = !0);
          for (var t = void 0, i = 0; i < e.list.length; i++) {
            var s = e.list[i];
            (t = {
              label_gemFunsion_name: {
                text: s.lvl + "级" + s.n + "（" + s.t + s.v + "）",
              },
              image_gemFunsion_icon: { skin: "stone/" + s.i + ".png" },
              lvl: s.lvl,
              n: s.n,
              t: s.t,
              v: s.v,
              id: s.id,
              i: s.i,
            }),
              this.baoshiArr.push(t);
          }
          this.list_gem_item.dataSource = this.baoshiArr;
        }
      }),
      (t.prototype.onListSelectGemDidClick = function (e) {
        if ("" != e.target.name && e.target.name) {
          var t = this.list_gem_item.selectedItem;
          if (0 == this.label_select_item1.text.length)
            return (
              (this.label_select_item1.text =
                t.lvl + "级" + t.n + "(" + t.t + t.v + ")"),
              (this.image_select_icon1.skin = "stone/" + t.i + ".png"),
              (this.label_select_item_delete1.visible = !0),
              this.showHeChengPriceMoney(t.lvl),
              (t.selIndex = this.list_gem_item.selectedIndex + 1),
              (this.firstObj = t),
              void this.list_gem_item.deleteItem(
                this.list_gem_item.selectedIndex
              )
            );
          if (0 == this.label_select_item2.text.length)
            return (
              (this.label_select_item2.text =
                t.lvl + "级" + t.n + "(" + t.t + t.v + ")"),
              (this.image_select_icon2.skin = "stone/" + t.i + ".png"),
              (this.label_select_item_delete2.visible = !0),
              this.showHeChengPriceMoney(t.lvl),
              (t.selIndex = this.list_gem_item.selectedIndex + 1),
              (this.secondObj = t),
              void this.list_gem_item.deleteItem(
                this.list_gem_item.selectedIndex
              )
            );
        }
      }),
      (t.prototype.onRenderGemItemHandler = function (e, t) {}),
      (t.prototype.showHeChengPriceMoney = function (e) {
        var t = 0 != this.label_select_item1.text.length,
          i = 0 != this.label_select_item2.text.length;
        if (t || i) {
          var s = 100 * (e + 1);
          (this.label_putong_haoyin.text = "(耗银：" + s + ")"),
            (this.btn_putonghecheng.disabled = !t || !i);
        } else this.label_putong_haoyin.text = "";
      }),
      (t.prototype.onSelectBaoShiDidClickAction = function (e) {
        "item_delete1" == e.target.name
          ? (this.list_gem_item.addItemAt(
              this.firstObj,
              this.firstObj.selIndex
            ),
            (this.label_select_item1.text = ""),
            (this.image_select_icon1.skin = ""),
            (this.label_select_item_delete1.visible = !1),
            (this.firstObj = {}))
          : "item_delete2" == e.target.name &&
            (this.list_gem_item.addItemAt(
              this.secondObj,
              this.secondObj.selIndex
            ),
            (this.label_select_item2.text = ""),
            (this.image_select_icon2.skin = ""),
            (this.label_select_item_delete2.visible = !1),
            (this.secondObj = {})),
          this.showHeChengPriceMoney(this.curLvl);
      }),
      (t.prototype.onHeChengAction = function (e) {
        if ("item_kuaisuhecheng" == e.target.name) {
          if (this.baoshiArr.length <= 1)
            return void ToastView.toastView("请换一下合成宝石级别");
          var t = {},
            i = {},
            s = !1,
            n = this.list_gem_item.dataSource;
          if (this.baoshiArr.length > 1)
            for (var l = 0; l < n.length; l++) {
              for (var o = n[l], a = l + 1; a < n.length; a++) {
                var c = n[a];
                if (o.t == c.t) {
                  (t = o), (i = c), (s = !0);
                  break;
                }
              }
              if (s) break;
            }
          s ||
            ((t = this.list_gem_item.dataSource[0]),
            (i = this.list_gem_item.dataSource[1])),
            (this.label_select_item1.alpha = 0),
            (this.label_select_item2.alpha = 0),
            Laya.Tween.to(this.label_select_item1, { alpha: 1 }, 900),
            Laya.Tween.to(this.label_select_item2, { alpha: 1 }, 900),
            (this.image_select_icon1.skin = "stone/" + t.i + ".png"),
            (this.image_select_icon2.skin = "stone/" + i.i + ".png"),
            (this.label_select_item1.text =
              t.lvl + "级" + t.n + "(" + t.t + t.v + ")"),
            (this.label_select_item2.text =
              i.lvl + "级" + i.n + "(" + i.t + i.v + ")"),
            (this.btn_kuaisuhecheng.disabled = !0),
            setTimeout(function () {
              WebSocketService.send({ c: 1286, d: { s1: t.id, s2: i.id } });
            }, 1100);
        } else if (
          "item_putonghecheng" == e.target.name &&
          this.firstObj.id &&
          this.secondObj.id
        ) {
          var _ = this.firstObj.id,
            h = this.secondObj.id;
          WebSocketService.send({ c: 1286, d: { s1: _, s2: h } });
        }
      }),
      (t.prototype.onLoadHeChengSuccessData = function (e) {
        0 == e.code
          ? (WebSocketService.send({
              c: 1284,
              d: { lvl: this.curLvl, pageNum: 0 },
            }),
            ToastView.toastView(e.msg),
            this.initHasBaoShiSelected(),
            Laya.stage.event("HomePageView", "refreshMoney"))
          : (ToastView.toastView(e.msg),
            (this.label_select_item1.text = ""),
            (this.label_select_item2.text = ""),
            (this.label_select_item_delete1.visible = !1),
            (this.label_select_item_delete2.visible = !1)),
          (this.btn_kuaisuhecheng.disabled = !1);
      }),
      (t.prototype.onLoadGemFusionPersonalData = function (e) {
        if (0 == e.code) {
          e.data.maxLvl;
          this.label_gemfunsion_tip.text = "(" + e.data.msg + ")";
        }
      }),
      (t.prototype.onDidClickLookGZSM = function () {
        var e = RulesView.showCaslRuleView("gemFusionGZSM");
        (e.y = 0), Laya.stage.addChild(e);
      }),
      (t.prototype.onGemFunsionBackFn = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.MarketController.AXGemFusionViewUI);
